<!DOCTYPE html>
<html>

<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">


    <title> - 科室信息</title>
    <meta name="keywords" content="">
    <meta name="description" content="">

    <link rel="shortcut icon" href="favicon.ico"> 
    <link href="${ctx!}/admin/css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
    <link href="${ctx!}/admin/css/font-awesome.css?v=4.4.0" rel="stylesheet">
    <link href="${ctx!}/admin/css/animate.css" rel="stylesheet">
    <link href="${ctx!}/admin/css/style.css?v=4.1.0" rel="stylesheet">
    <link href="${ctx!}/admin/css/bootstrap-datetimepicker.css" rel="stylesheet">
    <link href="${ctx!}/front/layui/css/layui.css" rel="stylesheet">

</head>

<body class="gray-bg">
    <div class="wrapper wrapper-content animated fadeInRight">
        <div class="row">
            <div class="col-sm-12">
                <div class="ibox float-e-margins">
                    <div class="ibox-title">
                        <h5>科室信息</h5>
                    </div>
                    <div class="ibox-content">
                         <form class="form-horizontal m-t layui-form layui-form-pane" id="form1">
                        	<input type="hidden" id="id" name="id" value="${(department.id)!}">
                            <div class="form-group">
                                <label class="col-sm-3 control-label">科室名称：</label>
                                <div class="col-sm-8">
                                    <input id="name" name="name" lay-verify="name" class="form-control" type="text" value="${(department.name)!}">
                                </div>
                            </div>

                            <div class="form-group">
                                <div class="col-sm-8 col-sm-offset-3">
                                    <button class="layui-btn" lay-submit lay-filter="go">立即提交</button>
                                </div>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>

    </div>


    <!-- 全局js -->
    <script src="${ctx!}/admin/js/jquery.min.js?v=2.1.4"></script>
    <script src="${ctx!}/admin/js/bootstrap.min.js?v=3.3.6"></script>

    <!-- 自定义js -->
    <script src="${ctx!}/admin/js/content.js?v=1.0.0"></script>
    <script src="${ctx!}/front/layui/layui.js" ></script>

    <script type="text/javascript">
	  layui.use(['form', 'upload'], function(){  
	  var form = layui.form();
  	  
	  form.verify({
		  name: function(value, item){
		    if(!value){
		      return '请输入科室名称';
		    }
		  }
		});      

	  form.on('submit(go)', function(data){
 			  $.ajax({
    		    type: "POST",
    		    dataType: "json",
    		    url: "${ctx!}/admin/department/save",
    		    data: $("#form1").serialize(),
                success: function(msg){
                	layer.msg(msg.msg||"操作成功", {time: 1000},function(){
	   	    				if(msg.isOk){
		   						var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
		   						parent.layer.close(index); 
		   						window.location.href = "${ctx!}/admin/department/index";
	   	    				}
	   					});
                },
                error: function(jqXHP,textStatus,errorThrown){
                    layer.alert(jqXHP.responseText);
                }
            })
   	    		
	    return false;
	  });
	});

    </script>
    
</body>

</html>
